#include "../../common/detail.hpp"
#include "../../client/rpc_client.hpp"

void callback(const Json::Value& result) {
    DLOG("result = %d", result.asInt());
}
int main()
{
    rcrpc::client::RpcClient client(true, "127.0.0.1", 8080);
    
    // 同步获取信息
    Json::Value params,result;
    params["num1"] = 12;
    params["num2"] = 21;
    bool ret = client.call("Add", params, result);
    if (ret) {
        ILOG("result = %d" , result.asInt());
    }

    // 异步获取信息
    rcrpc::client::RpcCaller::JsonAsyncResponse rsp_msg;
    params["num1"] = 121;
    params["num2"] = 21;
    bool ret1 = client.call("Add", params, rsp_msg);
    if (ret1) {
        result = rsp_msg.get();
        ILOG("result = %d" , result.asInt());
    }

    // 回调获取信息
    params["num1"] = 112;
    params["num2"] = 211;
    bool ret2 = client.call("Add", params, callback);
    DLOG("------\n");
    std::this_thread::sleep_for(std::chrono::seconds(1));
    return 0;

}